<template>
  <el-carousel
    :interval="4000"
    type="card"
    class="swiper"
    height="100%"
    @click="handleCar"
  >
    <el-carousel-item
      v-for="(item, index) in banner"
      :key="index"
      @click="handleItem"
    >
      <div class="img-box">
        <img
          v-lazy="item.imageUrl"
          alt
          class="img-swiper"
          @click="handleImg(item)"
        />
      </div>
    </el-carousel-item>
  </el-carousel>
</template>

<script>
export default {
  name: "swiper",
  props: {
    banner: {
      type: Array,
      default: [],
    },
  },
  data() {
    return {};
  },
  methods: {
    // 点击轮播图上的封面 可以进行播放  或者 跳转到播放页面
    handleImg(item) {
      console.log(item);
      switch(item.targetType) {
        case 1 : {
          // 歌曲 
        }; break;
        case 1004 : {
          // MV
        }; break;
        case 10 : {
          // 歌单
        }; break;
        case 3000 : {
          // 数字专辑
        }; break;
      }
    },
    handleItem() {
      console.log("item");
    },
    handleCar() {
      console.log("car");
    },
  },
  mounted() {
    console.log(this.banner);
  },
};
</script>
<style lang="less" scoped>
.swiper {
  width: 100%;
  height: 25%;
  overflow: hidden;
}
.el-carousel__item--card {
  height: 100%;
}
.img-swiper {
  position: absolute;
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
  background-size: cover;
}
.el-carousel__item h3 {
  color: #475669;
  font-size: 14px;
  opacity: 0.75;
  line-height: 200px;
  margin: 0;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}

.el-carousel__item--card {
  border-radius: 10px;
}
</style>